﻿using System;
using System.Windows.Forms;

namespace Masterduner.SourceStudio.Practices.DevelopmentLibrary.Utilities.DataConfiguration.Windows
{
    public partial class StartupWindow : Form
    {
        private int _counter = 0;
        private TrueExpression _trueExpr;
        private FalseExpression _falseExpr;

        public StartupWindow()
        {
            InitializeComponent();
            _trueExpr = ((args) => { _counter++; });
            _falseExpr = (
                    (args) =>
                    {
                        this.Hide();
                        MainWindow mainWindow = new MainWindow();
                        mainWindow.Show();
                        mainWindow.FormClosed += ((sender, e) => { this.Close(); });
                        this.tSplashTimer.Enabled = false;
                    }
                );
        }

        #region tSplashTimer_Tick
        private void tSplashTimer_Tick(object sender, EventArgs e)
        {
            IfElse.Do(_counter < 5, _trueExpr, _falseExpr);
        }
        #endregion
    }
}
